# Maintainer: Andrew Chadwick <a.t.chadwick@gmail.com>

_realname=graphene
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.2
pkgrel=1
arch=('any')
pkgdesc="A thin layer of graphic data types (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
options=('strip' '!debug')
license=("MIT")
url="https://ebassi.github.io/graphene/"
source=("${_realname}-${pkgver}.tar.gz::https://github.com/ebassi/graphene/archive/${pkgver}.tar.gz")
sha256sums=('87c682291fa38a131aaf9aaee17d053d7bd4ea5309d305a356619c95784b9b4d')

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  meson \
    --buildtype release \
    --prefix=${MINGW_PREFIX} \
    -Dgtk_doc=true \
    -Dinstalled_tests=false \
    ../${_realname}-${pkgver}

  ninja
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  meson test --print-errorlogs || true
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR=${pkgdir}${MINGW_PREFIX} ninja install

  sed -s "s|$(cygpath -m ${MINGW_PREFIX})|${MINGW_PREFIX}|g" -i "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/graphene-1.0.pc
  sed -s "s|$(cygpath -m ${MINGW_PREFIX})|${MINGW_PREFIX}|g" -i "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/graphene-gobject-1.0.pc

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE.txt"
}
